﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Home.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<%@ Import Namespace="XDeal.DAL.Entities" %>
<%@ Import Namespace="XDeal.BL.Implements" %>
<%@ Import Namespace="XDeal.Common.Web" %>
<%@ Import Namespace="XDeal.Common.Constants" %>
<%@ Import Namespace="Utility" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeaderContent" runat="server">
    <script src="<%=Url.Content("/Content/js/Cart/JSCart.js") %>" type="text/javascript"></script>
    <script src="<%=Url.Content("/Content/js/Cart/JSCustomer.js") %>" type="text/javascript"></script>

    <script src="<%=Url.Content("/Content/js/Cart/jquery.validate.js") %>" type="text/javascript"></script>
    

<link href="<%=Url.Content("/Content/DefaultTheme/css/cart.css") %>" rel="stylesheet" type="text/css" />
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="wrap_cart">
        <div class="cart_top"><img alt="" src="../../Content/DefaultTheme/images/gio_hang_bg.png" /> </div>
        <div class="cart_content">
            <div class="cart_title">
                <span class="c_title-ico" style="margin-left:10px;"><img alt="" src="../../Content/DefaultTheme/images/title_ico.png" /></span>
                <span class="c_title_text">thông tin đơn hàng của bạn</span>
            </div>
            <!-- begin cart content -->
            <div class="cart_content_title">
                <span class="title-del">Xóa</span>
                <span class="title-product">Sản phẩm/Dịch vụ</span>
                <span class="title-price">Đơn giá(VNĐ)</span>
                <span class="title-soluong">Số lượng</span>
                <span class="title-thanhtien">Thành tiền(VNĐ)</span>
            </div>
            <div class="cart_listitem">

                <%
                   Order od  = ViewData[ConstViewDataName.ListOfOrder] as Order;
                   if (od != null)
                   {

                       Deal dealIfo = new Deal();
                       DealBL dealBLDB = new DealBL();
                       double sumprice = 0;//tong tien cua 1 deal * so luong san pham
                       double totalPrice = 0;//tong tien san pham
                       double paymentCost = 0;//tien phi van chuyen
                       double totalPayment = 0;// tong tien san pham + phi van chuyen
                       double dealPrice = 0;//Gia deal sau khi da giam gia


                       List<OrderDetail> list = od.OrderDetails.ToList<OrderDetail>();
                       foreach (OrderDetail odt in list)
                       {
                           dealIfo = dealBLDB.GetByID(ConvertManage.ConvertToInt(odt.DealID_i, 0));
                           dealPrice = ConvertManage.ConvertToDouble(dealIfo.OldPrice_db, 0) * ConvertManage.ConvertToDouble(dealIfo.DiscountPercent_i, 0);
                           dealPrice = dealPrice / 100;
                           dealPrice = ConvertManage.ConvertToDouble(dealIfo.OldPrice_db, 0) - dealPrice;


                           sumprice = ConvertManage.ConvertToDouble(dealPrice * odt.Quantity_i, 0);
                           totalPrice += sumprice;
                           if (dealIfo.DeliveryCharge_db > paymentCost)
                           {
                               paymentCost = ConvertManage.ConvertToDouble(dealIfo.DeliveryCharge_db, 0);
                           }
                       
                %>

                <div class="cart_item" >
                    <div class="item_row"><span class="title-del" style="margin-left:0px;"><a href="javascript:" title="Xóa sản phẩm này"><img alt="" src="<%=Url.Content("/Content/DefaultTheme/images/btn_del_item.png") %>"  title="Xóa sản phẩm này"/></a></span></div>
                    <div class="item_row"><span class="title-product"><a href="<%: Url.Content("~/ThongTinDeal/" + dealIfo.ID_i + "/" + ConvertManage.GetSHTMLName(dealIfo.ShortName_s))%>"><%=dealIfo.ShortName_s%></a></span></div>
                    <div class="item_row"><span class="title-price"><%= dealPrice.ToString("n0")%></span></div>
                    <input type="hidden" id="hdDealIfoID" value='<%=dealIfo.ID_i %>' />
                    <input type="hidden" id="price" value='<%= dealPrice%>' />
                    <div class="item_row"><span class="title-soluong"><input type="text" id="tbxQuantity" name="tbxQuantity" value="<%=odt.Quantity_i.ToString() %>" style="width:50px;text-align:center;" maxlength="2" onkeypress="blockNotNumber(event)"/></span></div>
                    <div class="item_row"><span class="title-thanhtien"><%= sumprice.ToString("n0")%></span></div>
                </div><!-- end div.cart_item -->


                <%} %>


                <div class="sum_item">
                    <span class="sum_item_title"><p>Tổng cộng&nbsp;</p></span>
                    <span class="sum_item_value_price"><p><%=totalPrice.ToString("n0")%></p></span>
                </div>
                <div class="sum_item">
                    <span class="sum_item_title"><p>Phí vận chuyển&nbsp;</p></span>
                    <span class="sum_item_value"><p><%= paymentCost.ToString("n0")%><input type="hidden" id="shipping" value='<%=paymentCost%>' /></p></span>
                </div>
                <div class="sum_item" style="background:#e9e9e9;font-weight:bold;">
                    <span class="sum_item_title"><p>Tổng tiền thanh toán&nbsp;</p></span>
                    <span class="sum_item_value_total"><p><%=(paymentCost + totalPrice).ToString("n0")%></p></span>
                </div>
                <%}
                   else
                   {%><!--end if.od!=null -->
                   <div class="cart_item">
                        <span style="width:100%;float:left;text-align:center;margin-top:15px;margin-bottom:10px;color:Red;">Giỏ hàng trống</span>
                   </div>
                <%} %>
            </div>
            <div class="continous-shop">
                <span class="btn_ctn_b"><a href="<%=Url.Content("~/") %>">Tiếp tục mua hàng</a></span>
            </div>

            <%
                string display = "inline";
                if (GlobalVariables.Customer != null)
                {
                    display = "none";
                    %>
                    <div class="finish_order">
                        <span class="btn_finish_o"><a href="">Thanh toán</a></span>
                    </div>
                    <%
                }     
            %>

            <!-- end cart content -->
        </div><!-- end div.cart_content -->

        <%
            if (display == "inline")
            {
        %>
              
        <div class="cart_login">
           <div class="cart_title">
                <span class="c_title-ico"><img alt="" src="<%=Url.Content("/Content/DefaultTheme/images/title_ico.png") %>" /></span>
                <span class="c_title_text">đăng nhập nếu bạn đã có tài khoản</span>
            </div> 
            <div class="info_box">
                <div class="info_box_top"><img alt="" src="<%=Url.Content("/Content/DefaultTheme/images/order_box_top.png") %>" /></div>
                <div class="info_box_content">
                    
                        <div class="login_user">
                            <span class="email_lg email_pass_t">Email:</span>
                            <span class="email_input"><input type="text" id="tbxEmail" name="tbxEmail" />
                            </span>
                            <span class="error_email"></span>
                        </div>
                        <div class="login_pass">
                            <span class="pass_lg email_pass_t">Mật khẩu:</span>
                            <span class="pass_input"><input type="password" id="tbxPass" name="tbxPass" /></span>
                            <span class="error_pass"></span>
                        </div>
                    
                    <div class="login_control">
                        <span class="loss_password"><a href="">Quên mật khẩu</a></span>
                        <span class="loginbtn"><a href="Javascript:">Đăng nhập</a></span>
                    </div>
                </div><!-- end div.info_box_content -->
                <div class="info_box_bottom"><img alt="" src="<%=Url.Content("/Content/DefaultTheme/images/order_box_bottom.png") %>" /></div>
            </div><!-- end div.info_box -->
        </div><!-- end div.cart_login -->
          
        <%
            }     
        %>

        <%
            if (display == "inline")
            {
        %>
            
        <div class="cart_regist">
            <div class="cart_title">
                <span class="c_title-ico"><img alt="" src="<%=Url.Content("/Content/DefaultTheme/images/title_ico.png") %>" /></span>
                <span class="c_title_text">đăng ký nếu bạn chưa có tài khoản</span>
            </div> 
            <div class="info_box">
                <div class="info_box_top"><img alt="" src="<%=Url.Content("/Content/DefaultTheme/images/order_box_top.png") %>" /></div>
                <div class="info_box_content">
                    <div class="regist_note"><span style="float:left;margin-left:4px;margin-top:5px;color:#22272C;font-size:12px;">* Vui lòng điền đầy đủ thông tin bên dưới.</span></div>
                    <div class="basic_info">
                        <div class="regist_item"><span class="regist_title">Họ và tên:</span><span class="regist_input"><input type="text" id="tbxFullName" name="tbxFullName" /></span></div>
                        <div class="regist_item"><span class="regist_title">Email:</span><span class="regist_input"><input type="text" id="tbxEmailRegist" name="tbxEmailRegist" /></span></div>
                        <div class="regist_item"><span class="regist_title">Mật khẩu:</span><span class="regist_input"><input type="password" id="tbxPassRegist" name="tbxPassRegist" /></span></div>
                        <div class="regist_item"><span class="regist_title">Nhập lại mật khẩu:</span><span class="regist_input"><input type="password" id="tbxRePassRegist" name="tbxRePassRegist" /></span></div>
                    </div>
                    <div class="basic_info">
                        <div class="regist_item"><span class="regist_title">Tỉnh thành:</span><span class="regist_input">
                            <select id="Province" name="Province" style="width:205px;">
                                <option value='0' selected="selected">Chọn thành phố</option>
                            <%
                                List<Province> listProvice = new List<Province>();
                                ProvinceBL pBL = new ProvinceBL();
                                listProvice = pBL.GetAll();

                                foreach (Province pitem in listProvice)
                                {
                                    %>
                                        <option value='<%=pitem.ID_i.ToString() %>'><%=pitem.ProvinceName_s %></option>    
                                    <%
                                }
                                %>
                            
                                
                            </select>
                                
                            </span></div>
                        <div class="regist_item"><span class="regist_title">Quận huyện:</span><span class="regist_input"><select id="District" name="District" style="width:205px;"></select></span></div>
                        <div class="regist_item"><span class="regist_title">Địa chỉ:</span><span class="regist_input"><input type="text" id="tbxAddress" name="tbxAddress" /></span></div>
                        <div class="regist_item"><span class="regist_title">Điện thoại:</span><span class="regist_input"><input type="text" id="tbxPhone" name="tbxPhone" /></span></div>
                    </div>
                    <div class="regist_control">
                        <span class="fb_loading"></span>
                        <span class="regist_btn"><a href="Javascript:">Đăng ký</a></span>
                    </div>
                    
                </div><!-- end div.info_box_content -->
                <div class="info_box_bottom"><img alt="" src="<%=Url.Content("/Content/DefaultTheme/images/order_box_bottom.png") %>" /></div>
            </div><!-- end div.info_box -->
        </div><!-- end div.cart_regist -->
       
         <%
            }     
        %>

    </div><!-- end di.wrap_cart -->
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="RightContent" runat="server">
</asp:Content>
